package com.jinxin.platform.cdfaceacs.service.impl;

import com.alibaba.fastjson.JSONObject;
import com.jinxin.platform.base.common.pojo.InvokeCfg;
import com.jinxin.platform.base.common.pojo.JsonResult;
import com.jinxin.platform.base.common.support.BusinessDelegate;
import com.jinxin.platform.cdfaceacs.service.AcsControlModuleInvokeService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.Map;

/**
 * Description: apcos-acs
 * Created by 34759 on 2020/4/16 14:30
 */
@Service
@Slf4j
public class AcsControlModuleInvokeServiceImpl implements AcsControlModuleInvokeService {
    @Autowired
    private BusinessDelegate businessDelegate;
    @Value("${cdfaceacs.invoke-info.user-test.key}")
    private String key;
    @Value("${cdfaceacs.invoke-info.user-test.className}")
    private String className;
    @Value("${cdfaceacs.invoke-info.user-test.funName}")
    private String funName;

    // 测试获取参数接口
    @Override
    public String getLoginUserInfo(){
        InvokeCfg invokeCfg = new InvokeCfg();
        invokeCfg.setModuleKey(key);
        invokeCfg.setClassName(className);
        invokeCfg.setFunName(funName);
        HashMap<Object, Object> hashMap = new HashMap();
        invokeCfg.setArgs(hashMap);
        JsonResult invoke = this.businessDelegate.invoke(invokeCfg);
        log.info(invoke.toString());
        if (invoke.getSuccess()) {
            log.info("获取用户信息成功--"+invoke.toString());
            return invoke.getData().toString();
        } else {
           log.error("获取用户信息失败--"+invoke.toString());
            Map<String,String > userMap = new HashMap<>();
            userMap.put("userId","123");
            userMap.put("userAccount","1832222222" );
            userMap.put("userName","test" );
            userMap.put("userCellphoneNo","18506483993" );
            userMap.put("userEmail","965238856@qq.com" );

            return JSONObject.toJSONString(userMap);
        }

    }


}
